/**
 * Copyright:Copyright(c)2014-2017
 * Company:厦门市易致达物联网科技有限公司
 * @version 1.0
 */
package shop.controller.manage.customer;
import shop.core.common.bean.JSONResult;
import shop.core.common.bean.ManageContainer;
import shop.core.util.KeyValueHelper;
import shop.core.Services;
import shop.core.util.MD5;
import shop.services.manage.customer.CustomerService;
import shop.services.manage.customer.bean.Customer;
import shop.core.BaseController;
import shop.core.RequestHolder;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import shop.services.manage.system.bean.User;

import javax.servlet.http.HttpSession;

/**   
 * @类名称：CustomerAction      
 * @创建人：wzl
 * @创建时间：2018-05-24 下午14:51:56      
 * @版本号：1.0
 * @描述：     
 */
@Controller
@RequestMapping("/manage/customer/")
public class CustomerAction extends BaseController<Customer> {
    private static final Logger logger = LoggerFactory.getLogger(CustomerAction.class);
    @Autowired
    private CustomerService customerService;
    private static final String page_toList = "/manage/customer/customerList";
    private static final String page_toAdd = "/manage/customer/customerAdd";
    private static final String page_toEdit = "/manage/customer/customerEdit";
    public CustomerService getService() {
        return customerService;
    }

    private CustomerAction(){
        super.page_toList = page_toList;
        super.page_toAdd = page_toAdd;
        super.page_toEdit = page_toEdit;
    }

    /**
     * 添加客户
     *
     * @return jsonResult
     * @throws Exception
     */
    @RequestMapping(value = "insertCustomer", method = RequestMethod.POST)
    @ResponseBody
    public JSONResult insertCustomer(HttpSession session,Customer customer) throws Exception {
        JSONResult jsonResult = new JSONResult();
        User user = (User) session.getAttribute(ManageContainer.manage_session_user_info);
        customer.setCreateUser(user.getId());
        customerService.insert(customer);
        return jsonResult;
    }
}
